home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performResetToDefault.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.1 KB  |  121 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  Jan 26, 1999
  21. //  Author:         vangelis
  22. //
  23. //  Description:
  24. //      This script returns the weights of the selected
  25. //      smooth skin components/objects to their default value
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34.  
  35. global proc performResetToDefault()
  36. //
  37. // Description:
  38. //    This procedure returns the smooth skin weights of the 
  39. //    selected objects/components to their default values by executing
  40. //    the "skinPercent -rtd $skinCluster" command.  It uses the 
  41. //    current selection list to extract the objects and components. 
  42. //    When transforms are selected then the whole hierarchy of skinned
  43. //    surfaces under them will be included in the command. 
  44. //
  45. {
  46.     // Find all the selected components
  47.     //
  48.     string $sel[] = `ls -sl`;
  49.  
  50.     // Find the selected shapes
  51.     //
  52.     string $allShapes[] = `ls -sl -lf -dag -o`;
  53.  
  54.     string $shape;
  55.     int $count = 0;
  56.     for ($shape in $allShapes)
  57.     {
  58.         // Ignore if it is an intermediate object
  59.         //
  60.         int $io = `getAttr ($shape+".io")`;
  61.         if ($io == 1)
  62.             continue;
  63.         
  64.         string $parentL[] = `listRelatives -parent $shape`;
  65.         string $parent = $parentL[0];
  66.  
  67.         // Get the skinCluster attached to the object
  68.         //
  69.         string $skinCluster = findRelatedSkinCluster($shape);
  70.         if ($skinCluster == "")
  71.             continue;
  72.  
  73.         // Loop though all the selected components
  74.         // and select the ones that are related to the current shape
  75.         //
  76.         select -cl;
  77.         string $comp;
  78.         string $buf[];
  79.         for ($comp in $sel)
  80.         {
  81.             int $tok = tokenize($comp,".",$buf);
  82.  
  83.             // Component
  84.             //
  85.             if ($tok == 2 && $buf[0] == $parent)
  86.                 select -add $comp;
  87.  
  88.             // Whole shape
  89.             //
  90.             if ($tok == 1 && $buf[0] == $parent)
  91.             {
  92.                 select -r $parent;
  93.                 break;
  94.             }
  95.         }
  96.  
  97.         // If the selection list is empty then select the 
  98.         // whole shape
  99.         //
  100.         string $newSel[] = `ls -sl`;
  101.         if (size($newSel)== 0)
  102.             select -r $parent;
  103.  
  104.         // Execute the command for the given skin cluster
  105.         //
  106.         string $cmd = "skinPercent -rtd "+ $skinCluster;
  107.         catch(evalEcho($cmd));
  108.         $count++;
  109.     }
  110.     // Reset the selection
  111.     //
  112.     select -r $sel;
  113.  
  114.     if ($count == 0) {
  115.         error("No skinned items were selected.");
  116.     }
  117.  
  118. }
  119.  
  120.             
  121.